﻿/*
 * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：研发部
 * 日 期：2017.04.18
 * 描 述：角色添加	
 */
var acceptClick;
var auditorName = '';
var ProjectId = top.request('ProjectId');
var url;
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.bind();
        },
        bind: function () {
            $('#auditorId').lrselect({
                value: 'F_UserId',
                text: 'F_RealName',
                title: 'F_RealName',
                // 展开最大高度
                maxHeight: 110,
                // 是否允许搜索
                allowSearch: true,
                select: function (item) {
                    if (item) {
                        auditorName = item.F_RealName;
                    }
                }
            });
            if (ProjectId == "" || ProjectId == null || ProjectId == undefined) {
                url = "/LR_OrganizationModule/Post/GetCompanyTree";
            } else {
                url = "/LR_OrganizationModule/Post/GetOrganizationTree?ProjectId=" + ProjectId;
            }
            $('#department').lrselect({
                url: url,
                type: 'tree',
                maxHeight: 150,
                select: function (item) {
                    debugger;
                    var value = item.value;
                    if (!value || value == "-1") {
                        value = "";
                    }
                    $('#auditorId').lrselectRefresh({
                        url: top.$.rootUrl + '/LR_AuthorizeModule/UserRelation/GetRelationUserList',
                        param: { KeyValue: value, ProjectId: ProjectId }
                    });
                }
            })
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        var formData = $('#form').lrGetFormData();
        formData.auditorName = auditorName;
        formData.type = '3';//审核者类型1.岗位2.角色3.用户
        callBack(formData);
        return true;
    };
    page.init();
}